package com.zxk.weixinpay.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zxk.weixinpay.domain.Video;
import com.zxk.weixinpay.service.VideoService;
import io.swagger.annotations.*;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/video")
@Api(tags = "视频相关接口")
public class VideoController {

    @Autowired
    private VideoService videoService;

    /**
     * 查找所有的视频
     * @return
     */
    @ApiOperation(value = "查找所有视频",notes = "suoyoude")
    @GetMapping("page")
    public Object findAll(@RequestParam(value = "page",defaultValue = "1") Integer page,
                               @RequestParam(value = "size",defaultValue = "10") Integer size) {
        PageHelper.startPage(page,size);
        List<Video> list = videoService.findAll();
        PageInfo<Video> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    /**
     * 根据id找视频
     * @param id
     * @return
     */
    @ApiOperation(value="获取视频详细信息", notes="根据视频的id来获取视频详细信息")
    @GetMapping("find_by_id")
    public Video findById(@ApiParam @RequestParam(value = "video_id",required = true) Integer id) {
        return videoService.findByid(id);
    }



}
